import {FormInstance, TableColumnCtx} from "element-plus";
import {VNode} from "vue";

export interface TableColumnContext<T = any> extends Partial<Omit<TableColumnCtx<T>,
    "renderCell" | "renderHeader" | "showOverflowTooltip">>{
    visible?: boolean
    tag?: boolean
    tooltip?: boolean
    collapseButtons?: boolean
    maxCollapseButtons?: number
    options?: Array<{[key:string]: any}>
    render?: (scope: RenderScope) => VNode | TableColumnActions[] // 自定义单元格内容渲染（tsx语法）
}

export interface TableColumnActions {
    label?: string;
    auth?: string;
    type?: string;
    icon?: string;
    onClick: (scope: RenderScope) => void;
}

export type RenderScope<T = any> = {
    row: T;
    $index: number;
    column: TableColumnContext<T>;
    [key: string]: any;
};

export interface DataTableProps {
    api?: string
    data?: Record<string, any>
    height?: string | number
    index?: boolean
    border?: boolean
    stripe?: boolean
    pageSize?: number
    primaryKey?: string
    searchPosition?: string
    columns?: Array<TableColumnContext>
    enums?: any
    lazy?: boolean
    pagination?: boolean
    selection?: boolean
    selectOnRowClick?: boolean
    contextMenuExtra?: Array<any>|{[key:number]:Array<any>}
    beforeOpenContextMenu?: (data: {current: any, selections: Array<any>},  menus: Array<any>) => boolean
}